import { ElLoading } from 'element-plus';
// ============loading处理==================================================
let loadingInstance = null;
export const startLoading = (options) => {
	loadingInstance = ElLoading.service({
		lock: true,
		text: 'Loading',
		background: 'rgba(0, 0, 0, 0.7)',
		...options
	});
}
export const closeLoading = () => {
	loadingInstance.close();
}
// =======================================================================
export function downloadFile(data, name) {
	const a = document.createElement('a');
	a.download = decodeURIComponent(name);
	a.href = URL.createObjectURL(data);
	document.body.appendChild(a);
	a.click();
	a.remove();
	// 释放这个临时的对象url
	URL.revokeObjectURL(a.href);
};